package homework;


import java.util.Scanner;

public class Count {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.println("请输入一个字符串（里面含有中文，英文和数字）");
        String string = input.next();
        StringBuilder ChineseString = new StringBuilder();
        StringBuilder EnglishString = new StringBuilder();
        StringBuilder NumberStringBuilder = new StringBuilder();
        for (int i = 0; i < string.length(); i++) {
            switch (Character.getType(string.charAt(i))) {

                case 1:
                case 2:
                    EnglishString.append(string.charAt(i));
                    break;
                case 5: // 中文字符
                    ChineseString.append(string.charAt(i));
                    break;
                case 9: // 数字
                    NumberStringBuilder.append(string.charAt(i));
                    break;
                default:
                    break;
            }
        }

        System.out.println("字符串："+string+"  中");
        System.out.println("中文字符的个数为 "+ChineseString.length()+"  个");
        System.out.println("英文字符的个数为 "+EnglishString.length()+"  个");
        System.out.println("数字字符的个数为 "+NumberStringBuilder.length()+"  个");
    }
}
